// @ts-ignore
/* eslint-disable */
import request from "@/libs/request";


/** searchServers POST /api/mrs/servers */
export async function searchServers(options?: { [key: string]: any }) {
  const response = await request<API.BaseResponseListServers>('/api/mrs/servers', {
    method: 'GET',
  });
  return response;
}
/** searchNodes POST /api/mrs/nodes */
export async function searchNodes(options?: { [key: string]: any }) {
  const response = await request<API.BaseResponseListNodes>('/api/mrs/nodes', {
    method: 'GET',
  });
  return response;
}
/** searchInstances POST /api/mrs/instances */
export async function searchInstances(options?: { [key: string]: any }) {
  const response = await request<API.BaseResponseListInstances>('/api/mrs/instances', {
    method: 'GET',
  });
  return response;
}
/** searchHdfs POST /api/mrs/summary */
export async function searchHdfs(options?: { [key: string]: any }) {
  const response = await request<API.BaseResponseListHdfs>('/api/mrs/summary', {
    method: 'GET',
  });
  return response;
}
/** searchHive POST /api/mrs/hive */
export async function searchHive(options?: { [key: string]: any }) {
  const response = await request<API.BaseResponseListHive>('/api/mrs/hive', {
    method: 'GET',
  });
  return response;
}
/** searchYarn POST /api/mrs/yarn */
export async function searchYarn(options?: { [key: string]: any }) {
  const response = await request<API.BaseResponseListYarn>('/api/mrs/yarn', {
    method: 'GET',
  });
  return response;
}
/** searchHosts POST /api/mrs/hosts */
export async function searchHosts(options?: { [key: string]: any }) {
  const response = await request<API.BaseResponseListMrsHosts>('/api/mrs/hosts', {
    method: 'GET',
  });
  return response;
}


/** 更新接口 POST /api/mrs/update */
export async function update(body: API.UpdateParams, options?: { [key: string]: any }) {
  return request<API.BaseResponse<API.UpdateResult>>('/api/mrs/update', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
/** 新建规则 PUT /api/rule */
export async function updateRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'PUT',
    ...(options || {}),
  });
}
export async function deleteFilesUsingPost(
  body: API.FileDeleteRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponselong>("/api/mrs/deleteFiles", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: body,
    ...(options || {}),
  });
}

/** downloadLocal GET /api/mrs/download/ */
export async function downloadLocalUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.downloadLocalUsingGETParams,
  options?: { [key: string]: any }
) {
  return request<any>("/api/mrs/download/", {
    method: "GET",
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** listMrsFilesByPage GET /api/mrs/files */
export async function listMrsFilesByPageUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.listMrsFilesByPageUsingGETParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseListMrsFiles>("/api/mrs/files", {
    method: "GET",
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** uploadFile POST /api/mrs/upload */
export async function uploadFileUsingPost(
  body: {},
  file?: File,
  options?: { [key: string]: any }
) {
  const formData = new FormData();

  if (file) {
    formData.append("file", file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === "object" && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ""));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });


  return request<API.BaseResponsestring>("/api/mrs/upload", {
    method: "POST",
    data: formData,
    // @ts-ignore
    requestType: "form",
    ...(options || {}),
  });
}
